﻿using Sidvall.IdentityManager.UI.Messaging;

namespace Sidvall.IdentityManager.UI.ViewModels
{
    public abstract class PluginViewModelBase : Sidvall.UI.ViewModels.ViewModelBase
    {
        #region Public Members

        #region ContextParameter

        public ContextParameter _ContextParameter;
        public ContextParameter ContextParameter
        {
            get
            {
                return _ContextParameter;
            }
            protected set
            {
                _ContextParameter = value;
                RaisePropertyChanged("ContextParameter");
            }
        }

        #endregion

        #region Init

        public void Init(ContextParameter item)
        {
            this.ContextParameter = item;
        }

        #endregion

        #region OnPluginMessage

        protected void OnPluginMessage(IdentityManager.Data.PluginMessageType type)
        {
            var message = new PluginMessage(this)
            {
                PluginId = this.ContextParameter.PluginId,
                PluginMessageType = type,
            };
            Publish(message);
        }
        protected void OnPluginMessage(string filterContext)
        {
            var message = new PluginMessage(this)
            {
                PluginId = this.ContextParameter.PluginId,
                PluginMessageType = Data.PluginMessageType.FilterModified,
                FilterContext = filterContext,
            };
            Publish(message);
        }

        #endregion

        #endregion
        #region Constructors

        protected PluginViewModelBase()
        {
        }

        #endregion
    }
}